package com.hy.lightning.commons;

import java.util.HashMap;

public class EntityBean<K,V> extends HashMap<K, V>{

	private static final long serialVersionUID = 1L;

	private K[] keys;
	
	private V[] values;
	
	@SuppressWarnings("unchecked")
	public EntityBean<K,V> setKeys(K ...keys) {
		this.keys = keys;
		return this;
	}
	
	@SuppressWarnings("unchecked")
	public EntityBean<K,V> setValues(V ...values) {
		this.values = values;
		return this;
	}
	
	public EntityBean<K,V> load() {
		if(keys.length != values.length) throw new IllegalAccessError();
		for(int i = 0; i < keys.length; i++) {
			this.put(keys[i], values[i]);
		}
		return this;
	}
	
	public EntityBean(){};
	
	
	@SuppressWarnings("unchecked")
	public EntityBean(String keys, Object ...values) {
		this.keys = (K[]) keys.split(",");
		this.values = (V[]) values;
		load();
	}
}
